﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using ZXCompany.Models.Dao;
using DBUtil;
using ZXCompany.Models.Entity;
namespace ZXCompany.Models.Service
{
    //业务领域
    public class BusinessService
    {
        DaoFactory daofac = new DaoFactory();
        Database db = new Database();
        /// <summary>
        /// 获取整体image
        /// </summary>
        /// <returns></returns>
        public ZX_WholeInfo GetWholeInfo()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetWholeInfoDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }
        /// <summary>
        /// 获取战略咨询
        /// </summary>
        /// <returns></returns>
        public ZX_WholeInfoStrategy GetWholeStrategy()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetWholeInfoStrategyDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }


        /// <summary>
        /// 品质改善
        /// </summary>
        /// <returns></returns>
        public ZX_Product GetProduct()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetProductDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

        /// <summary>
        /// 培训中心
        /// </summary>
        /// <returns></returns>
        public List<ZX_TrainList> GetTrainList()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetTrainListDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

        /// <summary>
        /// 培训中心
        /// </summary>
        /// <returns></returns>
        public ZX_TrainList GetTrainListById(int id)
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetTrainListDao().SelectByID(id,sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

        /// <summary>
        /// 培训信息
        /// </summary>
        /// <returns></returns>
        public ZX_TrainInfo GetTrainInfo()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetTrainInfoDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

        /// <summary>
        /// 信息技术
        /// </summary>
        /// <returns></returns>
        public ZX_InfoSkill GetInfoSkill()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetInfoSkillDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

    }
}